package org.budo.canal.runningmonitor.util;

import org.budo.support.lang.util.ReflectUtil;

import com.alibaba.otter.canal.common.zookeeper.running.ServerRunningData;
import com.alibaba.otter.canal.common.zookeeper.running.ServerRunningListener;
import com.alibaba.otter.canal.common.zookeeper.running.ServerRunningMonitor;

/**
 * @author lmw
 */
public class ServerRunningMonitorUtil {
    public static ServerRunningData getServerRunningData(ServerRunningMonitor serverRunningMonitor) {
        ServerRunningData serverRunningData = (ServerRunningData) ReflectUtil.getFieldValue(ServerRunningMonitor.class, "serverData", serverRunningMonitor);
        return serverRunningData;
    }

    public static String getDestination(ServerRunningMonitor serverRunningMonitor) {
        String destination = (String) ReflectUtil.getFieldValue(ServerRunningMonitor.class, "destination", serverRunningMonitor);
        return destination;
    }

    public static ServerRunningListener getServerRunningListener(ServerRunningMonitor serverRunningMonitor) {
        ServerRunningListener serverRunningListener = (ServerRunningListener) ReflectUtil.getFieldValue(ServerRunningMonitor.class, "listener", serverRunningMonitor);
        return serverRunningListener;
    }
}